#!/usr/bin/env python
# -*- coding: utf-8 -*-

def two_array_sort(array1, array2):
    array1.sort()
    array2.sort()
    i = 0
    j = 0
    array3 = []
    while i < len(array1) or j < len(array2)-1:
        print i, j
        if array1[i] < array2[j]:
            array3.append(array1[i])
            i += 1
        else:
            array3.append(array2[j])
            j += 1

    return array3

if __name__ == '__main__':
    a1 = [9, 2, 7, 4]
    a2 = [3, 1, 8,11]
    print two_array_sort(a1, a2)
